package com.xhsj.user.pms.oareply.service;

import com.xhsj.user.pms.oareply.entity.TbPamPatentOaRecheckFile;
import com.xhsj.user.pms.oareply.mapper.TbPamPatentOaRecheckFileMapper;
import com.xhsj.user.pms.oareply.service.TbPamPatentOaRecheckFileService;
import com.xhsj.user.hr.base.BaseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xhsj.user.pms.oareply.vo.CorrectionFileListVo;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.io.Serializable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
/**
 * <p>
 * 专利OA复审文件 服务实现类
 * </p>
 *
 * @author liuqinghua
 * @since Jul 28, 2021 8:21:12 AM
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class TbPamPatentOaRecheckFileService extends BaseService<TbPamPatentOaRecheckFileMapper, TbPamPatentOaRecheckFile>{
    @Autowired
    private TbPamPatentOaRecheckFileMapper dao;

	/**
	 * 保存
	 * @author liuqinghua
	 * @date Jul 28, 2021 8:21:12 AM
	 */
    @Override
    public boolean save(TbPamPatentOaRecheckFile entity) {
        return super.save(entity);
    }

	/**
	 * 通过id获取数据
	 * @author liuqinghua
	 * @date Jul 28, 2021 8:21:12 AM
	 */
    @Override
    public TbPamPatentOaRecheckFile getById(Serializable id) {
        return super.getById(id);
    }

	/**
	 * 通过id删除数据
	 * @author liuqinghua
	 * @date Jul 28, 2021 8:21:12 AM
	 */
    @Override
    public boolean removeById(Serializable id) {
        return super.removeById(id);
    }

	/**
	 * 分页查询数据
	 * @author liuqinghua
	 * @date Jul 28, 2021 8:21:12 AM
	 */
    public IPage<TbPamPatentOaRecheckFile> selectPage(Map<String,Object> data) {
        int currentPage=1;
        if (!Objects.isNull(data.get("page"))) {
            currentPage=(Integer) data.get("page");
        }
        int pageSize=20;
        if (!Objects.isNull(data.get("size"))) {
            pageSize=(Integer) data.get("size");
        }

        TbPamPatentOaRecheckFile entity = JSON.parseObject(JSON.toJSONString(data), TbPamPatentOaRecheckFile.class);
        Page<TbPamPatentOaRecheckFile> page = new Page(currentPage,pageSize);
        QueryWrapper<TbPamPatentOaRecheckFile> wrapper = new QueryWrapper(entity);
        return super.selectPage(page, wrapper);
    }

	/**
	 * 查询所有数据
	 * @author liuqinghua
	 * @date Jul 28, 2021 8:21:12 AM
	 */
    @Override
    public List<TbPamPatentOaRecheckFile> selectAll() {
        return super.selectAll();
    }


       /**
           * @Description: 根据业务id删除
           * @Author: liuqinghua
           * @Date: 2021/8/3
           */
    public void deleteByDataId(Long dataId) {
        dao.deleteByDataId(dataId);
    }

    /**
     * @Description:专利OA驳回-获取驳回文件
     * @Author: liuqinghua
     * @Date: 2021/8/4
     */
    public IPage<CorrectionFileListVo> findReCheckFileList(Long dataId,Long page,Long pageSize) {
        Page<CorrectionFileListVo> page1 = new Page<>(page,pageSize);
        return dao.findReCheckFileList(page1,dataId);
    }
    /**
     * @Description:专利OA驳回-获取驳回文件不分页
     * @Author: liuqinghua
     * @Date: 2021/8/4
     */
    public List<CorrectionFileListVo> findReCheckFileListNotPage(Long dataId) {
        return dao.findReCheckFileList(dataId);
    }
}
